// Script simple para ponerse y alternar casco con la tecla  y Shift + 
{$CLEO .cs}

0000:

const
CascoNormal = 1974327007  // Hash del casco bsico
CascoMoto   = -189288785  // Hash del casco de motocross
VK_TAB      = 220
VK_O_MAS    = 16        
end

var
0@ : int // Estado (0 = sin casco, 1 = con casco)
1@ : int // Textura previa
2@ : int // Modelo previo
5@ : int // Modelo de casco a aplicar
end

0@ = 0

while true
    wait 0
    
    if and
    0256: player 0 defined 
    03EE: player 0 controllable
    jf continue

    // Detectar si se presiona TAB (Cdigo 9)
    if 0AB0: key_pressed VK_TAB
    then
        if 0@ == 0
        then
            // Si tambin se mantiene presionada la tecla  (Cdigo 220)
            if 0AB0: key_pressed VK_O_MAS
            then
                5@ = CascoMoto
            else
                5@ = CascoNormal
            end

            // Guardar modelo y textura actual de la cabeza (Bodypart 16)
            08F7: get_player 0 bodypart 16 textureCRC_to 1@ modelCRC_to 2@
            
            // Aplicar el casco correspondiente
            0784: set_player 0 textureCRC 5@ modelCRC 5@ bodypart 16
            070D: rebuild_player 0
            0@ = 1
        else
            // Restaurar la apariencia original
            0784: set_player 0 textureCRC 1@ modelCRC 2@ bodypart 16
            070D: rebuild_player 0
            0@ = 0
        end

        // Esperar a soltar TAB para evitar parpadeos
        while 0AB0: key_pressed VK_TAB
            wait 0
        end
    end
end